<!--
 * @Author: your name
 * @Date: 2021-05-25 08:24:46
 * @LastEditTime: 2021-05-25 13:28:32
 * @LastEditors: Please set LastEditors
 * @Description: In User Settings Edit
 * @FilePath: \5.25\logo\src\router\Login.vue
-->
<template>
  <div class="login">
    <div class="login">
      <el-form label-width="100px" class="demo-ruleForm">
        <el-form-item label="用户名" prop="user">
          <el-input type="text" v-model="user" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item label="密码" prop="pwd">
          <el-input type="password" v-model="pwd" autocomplete="off"></el-input>
        </el-form-item>

        <el-form-item>
          <el-button type="primary" @click="BtnLogin">提交</el-button>
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  data(){
    return{
      user:'',
      pwd:''
    }
  },
  methods:{
    async BtnLogin(){
      let res = await axios.post('/api/login',{
        user:this.user,
        pwd:this.pwd
      })
      if(res.data.code===200){
        window.localStorage.setItem('user',this.user)
        this.$router.push('/Service')
      }
    }
  }
};
</script>

<style>
  .login{
    width: 400px;
    height: 200px;
    margin: 0 auto;
    border: 3px dashed turquoise;
    text-align: center;
    line-height: 50px;
  }
</style>